home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 June / SGI Freeware 1998 June.iso / dist / fw_bind.idb / usr / freeware / catman / p_man / cat3 / resolver.3.z / resolver.3
Text File  |  1998-05-26  |  10KB  |  178 lines

  1. RESOLVER(3)                 BSD Programmer's Manual                RESOLVER(3)
  2.  
  3. NNAAMMEE
  4.      rreess__qquueerryy, rreess__sseeaarrcchh, rreess__mmkkqquueerryy, rreess__sseenndd, rreess__iinniitt, ddnn__ccoommpp,
  5.      ddnn__eexxppaanndd - resolver routines
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  9.      ##iinncclluuddee <<nneettiinneett//iinn..hh>>
  10.      ##iinncclluuddee <<aarrppaa//nnaammeesseerr..hh>>
  11.      ##iinncclluuddee <<rreessoollvv..hh>>
  12.  
  13.      rreess__qquueerryy(_c_o_n_s_t _c_h_a_r _*_d_n_a_m_e, _i_n_t _c_l_a_s_s_, _t_y_p_e, _u___c_h_a_r _*_a_n_s_w_e_r,
  14.              _i_n_t _a_n_s_l_e_n);
  15.  
  16.      rreess__sseeaarrcchh(_c_o_n_s_t _c_h_a_r _*_d_n_a_m_e, _i_n_t _c_l_a_s_s_, _t_y_p_e, _u___c_h_a_r _*_a_n_s_w_e_r,
  17.              _i_n_t _a_n_s_l_e_n);
  18.  
  19.      rreess__mmkkqquueerryy(_i_n_t _o_p, _c_o_n_s_t _c_h_a_r _*_d_n_a_m_e, _i_n_t _c_l_a_s_s_, _t_y_p_e, _c_o_n_s_t _c_h_a_r _*_d_a_t_a,
  20.              _i_n_t _d_a_t_a_l_e_n, _s_t_r_u_c_t _r_r_e_c _*_n_e_w_r_r, _u___c_h_a_r _*_b_u_f, _i_n_t _b_u_f_l_e_n);
  21.  
  22.      rreess__sseenndd(_c_o_n_s_t _u___c_h_a_r _*_m_s_g, _i_n_t _m_s_g_l_e_n, _u___c_h_a_r _*_a_n_s_w_e_r, _i_n_t _a_n_s_l_e_n);
  23.  
  24.      rreess__iinniitt();
  25.  
  26.      ddnn__ccoommpp(_c_o_n_s_t _c_h_a_r _*_e_x_p___d_n, _u___c_h_a_r _*_c_o_m_p___d_n, _i_n_t _l_e_n_g_t_h,
  27.              _u___c_h_a_r _*_*_d_n_p_t_r_s_, _*_*_l_a_s_t_d_n_p_t_r);
  28.  
  29.      ddnn__eexxppaanndd(_c_o_n_s_t _u___c_h_a_r _*_m_s_g_, _*_e_o_m_o_r_i_g_, _*_c_o_m_p___d_n, _c_h_a_r _*_e_x_p___d_n,
  30.              _i_n_t _l_e_n_g_t_h);
  31.  
  32.      hheerrrroorr(_c_o_n_s_t _c_h_a_r _*_s);
  33.  
  34.      hhssttrreerrrroorr(_i_n_t _e_r_r);
  35.  
  36. DDEESSCCRRIIPPTTIIOONN
  37.      These routines are used for making, sending and interpreting query and
  38.      reply messages with Internet domain name servers.
  39.  
  40.      Global configuration and state information that is used by the resolver
  41.      routines is kept in the structure ___r_e_s _.  Most of the values have reason-
  42.      able defaults and can be ignored.  Options stored in ___r_e_s_._o_p_t_i_o_n_s are de-
  43.      fined in _r_e_s_o_l_v_._h and are as follows.  Options are stored as a simple bit
  44.      mask containing the bitwise ``OR'' of the options enabled.
  45.  
  46.      RES_INIT
  47.               True if the initial name server address and default domain name
  48.               are initialized (i.e., rreess__iinniitt() has been called).
  49.  
  50.      RES_DEBUG
  51.               Print debugging messages.
  52.  
  53.      RES_AAONLY
  54.               Accept authoritative answers only.  With this option, rreess__sseenndd()
  55.               should continue until it finds an authoritative answer or finds
  56.               an error.  Currently this is not implemented.
  57.  
  58.      RES_USEVC
  59.               Use TCP connections for queries instead of UDP datagrams.
  60.  
  61.      RES_STAYOPEN
  62.               Used with RES_USEVC to keep the TCP connection open between
  63.               queries.  This is useful only in programs that regularly do many
  64.  
  65.  
  66.               queries.  UDP should be the normal mode used.
  67.  
  68.      RES_IGNTC
  69.               Unused currently (ignore truncation errors, i.e., don't retry
  70.               with TCP).
  71.  
  72.      RES_RECURSE
  73.               Set the recursion-desired bit in queries.  This is the default.
  74.               (rreess__sseenndd() does not do iterative queries and expects the name
  75.               server to handle recursion.)
  76.  
  77.      RES_DEFNAMES
  78.               If set, rreess__sseeaarrcchh() will append the default domain name to sin-
  79.               gle-component names (those that do not contain a dot).  This op-
  80.               tion is enabled by default.
  81.  
  82.      RES_DNSRCH
  83.               If this option is set, rreess__sseeaarrcchh() will search for host names
  84.               in the current domain and in parent domains; see hostname(7).
  85.               This is used by the standard host lookup routine
  86.               gethostbyname(3).  This option is enabled by default.
  87.  
  88.      RES_NOALIASES
  89.               This option turns off the user level aliasing feature controlled
  90.               by the HOSTALIASES environment variable.  Network daemons should
  91.               set this option.
  92.  
  93.      The rreess__iinniitt() routine reads the configuration file (if any; see
  94.      resolver(5))  to get the default domain name, search list and the Inter-
  95.      net address of the local name server(s).  If no server is configured, the
  96.      host running the resolver is tried.  The current domain name is defined
  97.      by the hostname if not specified in the configuration file; it can be
  98.      overridden by the environment variable LOCALDOMAIN. This environment
  99.      variable may contain several blank-separated tokens if you wish to over-
  100.      ride the ``search list'' on a per-process basis.  This is similar to the
  101.      sseeaarrcchh command in the configuration file.  Another environment variable
  102.      (``RES_OPTIONS'') can be set to override certain internal resolver op-
  103.      tions which are otherwise set by changing fields in the ___r_e_s structure or
  104.      are inherited from the configuration file's ooppttiioonnss command.  The syntax
  105.      of the ``RES_OPTIONS'' environment variable is explained in resolver(5).
  106.      Initialization normally occurs on the first call to one of the other re-
  107.      solver routines.
  108.  
  109.      The rreess__qquueerryy() function provides an interface to the server query mecha-
  110.      nism.  It constructs a query, sends it to the local server, awaits a re-
  111.      sponse, and makes preliminary checks on the reply.  The query requests
  112.      information of the specified _t_y_p_e and _c_l_a_s_s for the specified fully-qual-
  113.      ified domain name _d_n_a_m_e. The reply message is left in the _a_n_s_w_e_r buffer
  114.      with length _a_n_s_l_e_n supplied by the caller.
  115.  
  116.      The rreess__sseeaarrcchh() routine makes a query and awaits a response like
  117.      rreess__qquueerryy(), but in addition, it implements the default and search rules
  118.      controlled by the RES_DEFNAMES and RES_DNSRCH options.  It returns the
  119.      first successful reply.
  120.  
  121.      The remaining routines are lower-level routines used by rreess__qquueerryy().  The
  122.      rreess__mmkkqquueerryy() function constructs a standard query message and places it
  123.      in _b_u_f. It returns the size of the query, or -1 if the query is larger
  124.      than _b_u_f_l_e_n. The query type _o_p is usually QUERY, but can be any of the
  125.      query types defined in _<_a_r_p_a_/_n_a_m_e_s_e_r_._h_>. The domain name for the query is
  126.      given by _d_n_a_m_e. _N_e_w_r_r is currently unused but is intended for making up-
  127.      date messages.
  128.  
  129.      The rreess__sseenndd() routine sends a pre-formatted query and returns an answer.
  130.      It will call rreess__iinniitt() if RES_INIT is not set, send the query to the lo-
  131.      cal name server, and handle timeouts and retries.  The length of the re-
  132.      ply message is returned, or -1 if there were errors.
  133.  
  134.      The ddnn__ccoommpp() function compresses the domain name _e_x_p___d_n and stores it in
  135.      _c_o_m_p___d_n. The size of the compressed name is returned or -1 if there were
  136.      errors.  The size of the array pointed to by _c_o_m_p___d_n is given by _l_e_n_g_t_h.
  137.      The compression uses an array of pointers _d_n_p_t_r_s to previously-compressed
  138.      names in the current message.  The first pointer points to to the begin-
  139.      ning of the message and the list ends with NULL. The limit to the array
  140.      is specified by _l_a_s_t_d_n_p_t_r. A side effect of ddnn__ccoommpp() is to update the
  141.      list of pointers for labels inserted into the message as the name is com-
  142.      pressed.  If _d_n_p_t_r is NULL, names are not compressed.  If _l_a_s_t_d_n_p_t_r is
  143.      NULL, the list of labels is not updated.
  144.  
  145.      The ddnn__eexxppaanndd() entry expands the compressed domain name _c_o_m_p___d_n to a
  146.      full domain name.  The compressed name is contained in a query or reply
  147.      message; _m_s_g is a pointer to the beginning of the message.  The uncom-
  148.      pressed name is placed in the buffer indicated by _e_x_p___d_n which is of size
  149.      _l_e_n_g_t_h. The size of compressed name is returned or -1 if there was an er-
  150.      ror.
  151.  
  152.      The external variable _h___e_r_r_n_o is set whenever an error occurs during re-
  153.      solver operation.  The following definitions are given in _<_n_e_t_d_b_._h_>:
  154.  
  155.      #define NETDB_INTERNAL -1  /* see errno */
  156.      #define NETDB_SUCCESS  0   /* no problem */
  157.      #define HOST_NOT_FOUND 1   /* Authoritative Answer Host not found */
  158.      #define TRY_AGAIN      2   /* Non-Authoritive not found, or SERVFAIL */
  159.      #define NO_RECOVERY    3   /* Nonrecoverable: FORMERR, REFUSED, NOTIMP */
  160.      #define NO_DATA        4   /* Valid name, no data for requested type */
  161.  
  162.      The hheerrrroorr() function writes a message to the diagnostic output consist-
  163.      ing of the string parameter _s, the constant string ": ", and a message
  164.      corresponding to the value of _h___e_r_r_n_o _.
  165.  
  166.      The hhssttrreerrrroorr() function returns a string which is the message text cor-
  167.      responding to the value of the _e_r_r parameter.
  168.  
  169. FFIILLEESS
  170.      /etc/resolv.conf      See resolver(5).
  171.  
  172. SSEEEE AALLSSOO
  173.      gethostbyname(3),  hostname(7),  named(8),  resolver(5);  RFC1032,
  174.      RFC1033, RFC1034, RFC1035, RFC974; SMM:11, ``Name Server Operations Guide
  175.      for BBIINNDD''
  176.  
  177. 4th Berkeley Distribution      December 11, 1995                             3
  178.